//
//  Dc_HotTableViewCell.m
//  艾薇贝儿
//
//  Created by dllo on 15/9/2.
//  Copyright (c) 2015年 dllo－－邴鹏超. All rights reserved.
//

#import "Dc_HotTableViewCell.h"
#import "Dc_CollectionViewCell.h"
#import "Dc_HotViewController.h"
#import "AppDelegate.h"

@implementation Dc_HotTableViewCell
{
    NSMutableArray * _array;
    DcFirstModel * _mo;
   
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _array=[[NSMutableArray alloc]init];
        [self setview];
        
    }
    return self;
}
-(void)setview{
    //ios6推出的瀑布流式
    UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    //设置item大小  每个小模块的大小
    flowLayout.itemSize = CGSizeMake(100*OffWidth, 100*OffHeight);
    
    //设置行间距
    flowLayout.minimumLineSpacing = 50*OffWidth;
    //设置列间距
    flowLayout.minimumInteritemSpacing = 1*OffHeight;
    
    //设置item上下左右间距
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 20, 20, 20);
    
    //集合视图
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 10*OffHeight, 375*OffWidth, 320*OffHeight)  collectionViewLayout: flowLayout];
    self.collectionView.backgroundColor = [UIColor lightGrayColor];
    //指定代理人
   self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.contentView addSubview:_collectionView];
    UIColor *image = [UIColor colorWithPatternImage:[UIImage imageNamed:@"6.jpg"]];
    _collectionView.backgroundColor = image;
    
    //注册cell
    [_collectionView registerClass:[Dc_CollectionViewCell class] forCellWithReuseIdentifier:@"reuseId"];
    

    
}
#pragma mark - collection Delegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{       return 6;
    
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    //直接从重用池取cell，reuseIdentifier一定要和注册时一致
   Dc_CollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseId" forIndexPath:indexPath];
    
   DcFirstModel * mo=[self.modelarray objectAtIndex:indexPath.row];
    
    
    
    [cell model:mo];
 
    return cell;
}

//点击方法
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
 
    DcFirstModel * mod=[self.modelarray objectAtIndex:indexPath.row];
      [self.delegate chuanaction:mod.action  chuanimage:mod.picUrl name:mod.name author:mod.author];
  
}


-(void)modle:(DcFirstModel * )model{
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
